package main

import "fmt"

func main() {
	fmt.Println("---if-else---")
	ifCondition()
	fmt.Println("---switchCond---")
	switchCond()
}

func ifCondition() {
	a := 1
	b := true
	str := "string"
	if a == 1 {
		fmt.Println("a==1")
	}
	if b {
		fmt.Println("b true")
	}
	if str == "string" {
		fmt.Println("str==string")
	}

	if a < 1 {
		fmt.Println("a<1")
	} else {
		fmt.Println("a>=1")
	}
}

func switchCond() {
	/* 定义局部变量 */
	var grade string = "B"
	const (
		Unkonw = 0
		Male   = 1
		Female = 2
	)

	var gender int = 1
	switch gender {
	case Male:
		grade = "男"
	case Female:
		grade = "女"
	case Unkonw:
	default:
		grade = "未知"
	}

	switch {
	case grade == "男":
		fmt.Println("男 ")
	case grade == "女":
		fmt.Println("女 ")
	case grade == "未知":
	default:
		fmt.Println("未知 ")
	}
	fmt.Println("性别是 ", grade)
}
